﻿//JumbotCms_4.1 Final
using System;
using System.Text;
using System.Data;
using Jumbot.Common;
namespace JumbotCms.Common
{
    public class CreateJson : BasicPage
    {
        /// <summary>
        /// 生成系统配置JS
        /// </summary>
        /// <param name="doh"></param>
        public void CreateSystemInfo(Jumbot.DataOper.DbOperHandler doh)
        {
            string TempStr = string.Empty;
            JumbotCms.DataObject.Site Site = new JumbotCms.DataObject.Site(doh);
            string _Name, _Url, _Dir, _Keywords, _Description, _ICP, _UserItem, _WriterItem, _Service, _ForumUrl, _LoginUrl, _LogoutUrl, _RegisterUrl, _GetPasswordUrl;
            _Name = Site.Name;
            _Url = Site.Url;
            _Dir = Site.Dir;
            _Keywords = Site.Keywords.Replace("|", ",");
            _Description = Site.Description.Replace("|", ",");
            _ICP = Site.ICP;
            _UserItem = Site.UserItem;
            _WriterItem = Site.WriterItem;
            _Service = Site.Service;
            _ForumUrl = Site.ForumUrl;
            _LoginUrl = Site.LoginUrl;
            _LogoutUrl = Site.LogoutUrl;
            _RegisterUrl = Site.RegisterUrl;
            _GetPasswordUrl = Site.GetPasswordUrl;
            TempStr = "var $$_JSON_Site = {" +
                "name: '" + _Name + "'," +
                "url: '" + _Url + "'," +
                "dir: '" + _Dir + "'," +
                "keywords: '" + _Keywords.Replace("\\", "\\\\") + "'," +
                "description: '" + _Description.Replace("\\", "\\\\") + "'," +
                "useritem: '" + _UserItem.Replace("\\", "\\\\") + "'," +
                "writeritem: '" + _WriterItem.Replace("\\", "\\\\") + "'," +
                "service: '" + _Service.Replace("\\", "\\\\") + "'," +
                "icp: '" + _ICP + "'" +
                "}";
            Jumbot.Common.DirFile.SaveFile(TempStr, "~/_data/json/_site.js");

            TempStr = "var site = new Object();" + vbCrlf +
                "site.Name = '" + _Name + "';" + vbCrlf +
                "site.Url = '" + _Url + "';" + vbCrlf +
                "site.Dir = '" + _Dir + "';" + vbCrlf +
                "site.Keywords = '" + _Keywords.Replace("\\", "\\\\") + "';" + vbCrlf +
                "site.Description = '" + _Description.Replace("\\", "\\\\") + "';" + vbCrlf +
                "site.UserItem = '" + _UserItem + "';" + vbCrlf +
                "site.WriterItem = '" + _WriterItem + "';" + vbCrlf +
                "site.Service = '" + _Service.Replace("\\", "\\\\") + "';" + vbCrlf +
                "site.ForumUrl = '" + _ForumUrl.Replace("\\", "\\\\") + "';" + vbCrlf +
                "site.LoginUrl = '" + _LoginUrl.Replace("\\", "\\\\") + "';" + vbCrlf +
                "site.LogoutUrl = '" + _LogoutUrl.Replace("\\", "\\\\") + "';" + vbCrlf +
                "site.RegisterUrl = '" + _RegisterUrl.Replace("\\", "\\\\") + "';" + vbCrlf +
                "site.GetPasswordUrl = '" + _GetPasswordUrl.Replace("\\", "\\\\") + "';" + vbCrlf +
                "site.ICP = '" + _ICP + "';";
            Jumbot.Common.DirFile.SaveFile(TempStr, "~/_data/SysConfig.js");
        }
    }
}
